[% setvar title Proposal to utilize C<*> as the prefix to magic subroutines %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>Proposal to utilize <code>*</code> as the prefix to magic subroutines</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: Jonathan Scott Duff &lt;<a href='mailto:duff@pobox.com'>duff@pobox.com</a>&gt;
  Date: 7 Aug 2000
  Last Modified: 1 Sep 2000
  Mailing List: <a href='mailto:perl6-language@perl.org'>perl6-language@perl.org</a>
  Number: 59
  Version: 2
  Status: Developing</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>Perl has always claimed the ALL-CAPS names for itself, I propose we
give them back to the programmer.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>Perl steals subroutine names from the programmer.  By prefixing the
Perl-special subroutines with a character that is not a valid prefix
for Perl programmers, we separate what belongs to Perl and what
belongs to the user.</p>
<p>With the proliferation of special subroutine names (BEGIN, END, INIT,
CHECK, etc.) the all capital subroutine names available to the
programmer has steadily shrunk.  Rather than stealing subroutines from
the programmer, we should create a space just for Perl.</p>
<pre>	sub *BEGIN {
	    # do compile-time stuff
	    # Perl-special 
	}

	sub BEGIN {
	    # No relation to the former. Purely user space.
	    # The user may have his/her own reasons for naming his
	    # subroutines this way.  (e.g., it fits the conception model
	    # that the software is build upon/around/through)
	}</pre>
<p>The visual distinction lets the programmer know that something special
is happening here and that this is not your average run-of-the-mill
subroutine.  The added <code>*</code> prefix also serves as a guide to the perl
compiler that these subroutines may be treated specially.</p>
<p>Another area where could be useful is in conjunction with Damian
Conway's <code>want()</code> proposal.  As his proposal currently stands, the
programmer can not name a package LIST or SCALAR and use it with the
proposed <code>want()</code>.  Perl has always claimed all lowercase package
names for itself, but never ALLCAPS package names.</p>
<a name='Examples'></a><h2>Examples</h2>
<pre>	switch ([want]) {
	    case '*LIST'	{ return @array; }
	    case '*SCALAR'	{ return $foo; }
	    case 'LIST'		{ return $MyListObj; }
	}

	sub *BEGIN	{ ... }
	sub *END	{ ... }
	sub *INIT	{ ... }
	sub *AUTOLOAD	{ ... }
	sub *TIESCALAR	{ ... }
	sub *FETCH	{ ... }  </pre>
<a name='Potential problems'></a><h2>Potential problems</h2>
<p>Makes Perl-special subroutines different from user subroutines.  This
implies yet another special case.</p>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>Um ... that's up to the internals people.</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<p>Perl 5.6.0 documentation</p>
<p>RFC 21 (v1): Replace <code>wantarray</code> with a generic <code>want</code> function</p>
</div>
